<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //节流检测值
        let i = null
        //节流第一步：声明变量储存触法时间
        let time = null
        document.documentElement.addEventListener('mousemove', () => {
            //节流第二步：判断两次间隔的时间是否超过节流阀
            let newtime = + new Date()
            if (newtime - time >= 300) {
                i++
                console.log(`这是我第${i}次触发`);
                //节流第三步：存储本次触发时间
                time = newtime
            }
        })
    </script>

</body>

</html>